

export default {
    format (number) {
        number = number + '';
        if (number === '0') return number;
        let arr = number.split('').reverse();
        let result = '';
        let index = 0;
        let symbol = ['+', '-', '*', '/', '='];
        arr.forEach((item, i) => {
            index++;
            if (symbol.indexOf(item) > -1) {
                index = 0;
                result += item;
            } else {
                result += item + ((index % 3 === 0 && index !== 0 && arr[i+1] && symbol.indexOf(arr[i+1]) === -1) ? ',' : '');
            }
        });
        return result.split('').reverse().join('');
    }
}
